package com.deft.design.strategy.impl;

import com.deft.design.strategy.ICouponDiscount;

import java.math.BigDecimal;

/**
 * @author Hide丶love
 * @date 2022/05/19
 **/
public class ZjCouponDiscount implements ICouponDiscount<Double> {
    @Override
    public BigDecimal discountAmount(Double couponInfo, BigDecimal skuPrice) {
        BigDecimal discountAmount = skuPrice.subtract(new BigDecimal(couponInfo));
        if (discountAmount.compareTo(BigDecimal.ZERO) < 1) {
            return BigDecimal.ONE;
        }
        return discountAmount;
    }
}
